#include <iostream>
class MyClass 
{
    public:
        MyClass();
        ~MyClass();
        MyClass(MyClass &src);
        MyClass& operator= (MyClass &src);
    private:
        friend std::ostream& operator<< (std::ostream &cout,MyClass &my);
        int data_;
};

MyClass::MyClass()
{
    std::cout << "MyClass 构造函数" << std::endl;
    data_ = 0;
}

MyClass::~MyClass()
{
    std::cout << "MyClass 析构函数" << std::endl;
}

MyClass::MyClass(MyClass &src)
{
    std::cout << "MyClass 拷贝构造函数" << std::endl;
    this->data_ = src.data_;
}

MyClass& MyClass::operator= (MyClass &src)
{
    std::cout << "MyClass 赋值操作符" << std::endl;
    this->data_ = src.data_;
    return *this;
}

std::ostream& operator<< (std::ostream &cout,MyClass &my)
{
    cout << "Myclass.data_ = "<< my.data_ << std::endl; 
    return cout;
}


int main() {
    
    MyClass myclass1;
    MyClass myclass2 = myclass1;
    MyClass myclass3;
    myclass3 = myclass2;

    std::cout << myclass1 << myclass2;
    return 0;
}                             // output: operator++()operator++()operator++()